package cn.edu.scau.cmi.chenyaoquan.composite.consistent;

import com.alibaba.fastjson.JSON;

import javafx.fxml.FXML;
import javafx.scene.control.TextArea;

public class ConsistentController {
    @FXML
    private  TextArea textArea;
    
	public  void getConsistent() {

	ConsistentComponent  alibaba = new ConsistentComposite();
	ConsistentComponent taobao = new ConsistentComposite();
	ConsistentComponent  zhifubao = new ConsistentComposite();
	ConsistentComponent  tianmao = new ConsistentComposite();
	((ConsistentComposite) alibaba).setName("alibaba");
	((ConsistentComposite) taobao).setName("taobao");
	((ConsistentComposite) zhifubao).setName("zhifubao");
	((ConsistentComposite) tianmao).setName("tianmao");
	ConsistentComponent alibaba_employee = new ConsistentLeaf();
	ConsistentComponent taobao_employee = new ConsistentLeaf();
	ConsistentComponent zhifubao_employee = new ConsistentLeaf();
	ConsistentComponent tianmao_employee = new ConsistentLeaf();
	((ConsistentLeaf) alibaba_employee).setName("alibaba_employee");	
	((ConsistentLeaf) taobao_employee).setName("taobao_employee");
	((ConsistentLeaf) zhifubao_employee).setName("zhifubao_employee");
	((ConsistentLeaf) tianmao_employee).setName("tianmao_employee");
	alibaba.addChild(alibaba_employee);
	alibaba.addChild(taobao);
	alibaba.addChild(zhifubao);
	taobao.addChild(taobao_employee);
	taobao.addChild(tianmao);
	zhifubao.addChild(zhifubao_employee);
	tianmao.addChild(tianmao_employee);

	textArea.appendText(JSON.toJSONString(alibaba.getChildren() , true));
	
	}
}
